<?php
include "header.php";
include "../dbase/db.php";
$id=intval($_GET['id']);
if(empty($_POST['sub'])){
    $sql=mysql_query("select * from catagory where id=$id");
    $data=mysql_fetch_assoc($sql);
    ?>
    <form action="" method="post">
        <label>栏目名称：</label>
        <input type="text" name="catname" value="<?php echo $data["catname"] ?>">
        <in type="hidden" name="id" value="<?php echo $data['id'] ?>">
            <input type="submit" name="sub">
    </form>
    <?php
}
else{
    $catname=trim($_POST['catname']);
    //$id=trim($_POST['id']);
    $sql=mysql_query("update catagory set catname='$catname' where id=$id");
    if($sql){
        $a=<<<fgd
        <script>
        alert("修改成功");
        window.location.href="category.php"; 
        </script>
fgd;
        echo $a;
    }

    else{
        die("修改失败");
    }
}